function random(number) {
    return Math.floor(Math.random() * (number + 1));
}

function bgChange() {
    const ranCol = `rgb(${random(255)},${random(255)},${random(255)})`;
    return ranCol;
}

const divs = document.querySelectorAll("div.box");
for (let i = 0; i < divs.length; i++) {
    divs[i].onclick = function (event) {
        console.log(event)
        event.target.style.backgroundColor = bgChange();
    }
}